new Vue({
    el: '#app',
    data() {
        return {
            form: {
                Merchant_SerialNumber: "",
                Merchant_Type: '',
                Enterprise_Info_SerialNumber: $.cookie("enterprise"),
            },
            rules: {
                Merchant_Type: [
                    { required: true, message: '请输入商户类型', trigger: 'blur' },
                ],
            },
            loading:false
        }
    },
    mounted() {
    },
    methods: {
        submitForm(formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    this.loading = true
                    const this_ = this
                    console.log(this.form)
                    $.ajax({
                        type: 'POST',
                        url: DomainName + '/getAddAction?token=' + $.cookie("token"),
                        data: {
                            Data: JSON.stringify({ merchant_info : [this_.form] }),
                        },
                        complete: function (XMLHttpRequest) {
                            this_.loading = false
                            if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
                                window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
                            }
                        },
                        success: function (Result) {
                            console.log(Result)
                            if (Result.Status == 'success') {
                                this_.$message({
                                    message: '添加成功',
                                    type: 'success'
                                });
                                window.history.go(-1)
                            }
                        },
                        dataType: "json"
                    });
                } else {
                    this.$message.error('请检查表单是否填写正确');
                    return false;
                }
            });
        }
    },
})